import { Button, Modal, Form, Input, message } from 'antd';
import { addReason } from '../../../../utils/cbt/sendRequset'
const Add = (props) => {
    const { open, cancleBtn,getMsg } = props
    // onChange(eidtData)
    console.log("进入的添加");
    const tailLayout = {
        wrapperCol: {
            offset: 17,
            span: 20,
        },
    };
    const onFinish = (values) => {
        values.reason_create_time = (new Date()).Format("yyyy-MM-dd HH:mm:ss")
        addReason(values).then(res => {
            if (res.code == 200) {
                message.success('添加成功')
                cancleBtn()
                getMsg()//渲染数据
            }else{
                message.error('添加失败')
            }
        })
    };
    const handleCancel = () => {
        cancleBtn();
    };
    return (
        <Modal
            title="退货原因添加"
            open={open}
            footer={null}
            onCancel={handleCancel}
            destroyOnClose='true'
        >
            <Form
                name="basic"
                labelCol={{
                    flex: '80px',
                }}
                labelAlign="left"
                labelWrap
                wrapperCol={{
                    flex: 1,
                }}
                colon={false}
                initialValues={{ reason: '' }}
                preserve={false}
                onFinish={onFinish}
            >
                <Form.Item
                    label="原因"
                    name="reason"
                    rules={[
                        {
                            required: true,
                        },
                    ]}
                >
                    <Input />
                </Form.Item>
                <Form.Item {...tailLayout}>
                    <Button htmlType="button" onClick={handleCancel}>
                        取消
                    </Button>
                    <Button type="primary" htmlType="submit" style={{ marginLeft: '10px' }}>
                        确认
                    </Button>
                </Form.Item>

            </Form>
        </Modal >
    );
};
export default Add;